﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using LibHuman;
namespace Human
{
	public class frm_DNNL_truocthoihan_theoquy_lb : System.Windows.Forms.Form
    {

        #region Danh sach cb_cnv de nghi nang luong
        private DataSet ds =new DataSet();
        string tungay = "", denngay = "", ReportName = "", 
            msg = "DANH SÁCH CB - CNV ĐỀ NGHỊ NÂNG LƯƠNG", title = "", s_mmyy = "",s_bophan="",user_dn="";
        AccessData mDb = new AccessData();
        DataSet ds_nhomn = new DataSet();
        string s_manhom = "", s_tennhom = "";
        Language lan = new Language();
        private bool admin = false;
		DataTable dt_thang = new DataTable();
		DataTable dt_nam = new DataTable();
        DataTable dt_ngach = new DataTable();
        private CheckBox checkxem;
        private Button btnketthuc;
        private Button btnchon;
        private Label label4;
        private Label label3;
        private ComboBox cmbhoten;
        private TextBox txttongso;
        private TextBox txtmanv;
        private GroupBox groupBox1;
        private CheckBox checkupdate;
        private CheckBox checkin;
        private CheckBox chk_uphd;
        private haison haison1;
        private Label lbl_nhom;
        private ComboBox cbo_nhom;
        private TextBox txt_tieude;
        private Label label2;
        private CheckedListBox chkl_nhomngach;
        private GroupBox groupBox2;
        private DataGridView dgvDanhSach;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn8;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn10;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn11;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn12;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn13;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn14;
        private DataGridViewTextBoxColumn nhomngach;
        private DataGridViewTextBoxColumn tennhom;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn15;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn16;
		private System.ComponentModel.Container components = null;
        #endregion
        public frm_DNNL_truocthoihan_theoquy_lb(bool m_admin,string s_makp,string s_userdn)
		{
			InitializeComponent();
            lan.Read_Language_to_Xml(this.Name.ToString(), this);
            lan.Changelanguage_to_English(this.Name.ToString(), this);
            admin = m_admin;
            s_bophan = s_makp;
            user_dn = s_userdn;
		}
        AccessData mDB = new AccessData();
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frm_DNNL_truocthoihan_theoquy_lb));
            this.checkxem = new System.Windows.Forms.CheckBox();
            this.btnketthuc = new System.Windows.Forms.Button();
            this.btnchon = new System.Windows.Forms.Button();
            this.label4 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.cmbhoten = new System.Windows.Forms.ComboBox();
            this.txttongso = new System.Windows.Forms.TextBox();
            this.txtmanv = new System.Windows.Forms.TextBox();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.checkupdate = new System.Windows.Forms.CheckBox();
            this.checkin = new System.Windows.Forms.CheckBox();
            this.chk_uphd = new System.Windows.Forms.CheckBox();
            this.lbl_nhom = new System.Windows.Forms.Label();
            this.cbo_nhom = new System.Windows.Forms.ComboBox();
            this.txt_tieude = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.chkl_nhomngach = new System.Windows.Forms.CheckedListBox();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.dgvDanhSach = new System.Windows.Forms.DataGridView();
            this.haison1 = new Human.haison();
            this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn12 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn13 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn14 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.nhomngach = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.tennhom = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn15 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn16 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dgvDanhSach)).BeginInit();
            this.SuspendLayout();
            // 
            // checkxem
            // 
            this.checkxem.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.checkxem.Checked = true;
            this.checkxem.CheckState = System.Windows.Forms.CheckState.Checked;
            this.checkxem.Location = new System.Drawing.Point(569, 528);
            this.checkxem.Name = "checkxem";
            this.checkxem.Size = new System.Drawing.Size(85, 17);
            this.checkxem.TabIndex = 17;
            this.checkxem.Text = "Xem trang in";
            this.checkxem.UseVisualStyleBackColor = true;
            this.checkxem.CheckedChanged += new System.EventHandler(this.checkxem_CheckedChanged);
            this.checkxem.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cmbquy_KeyDown);
            // 
            // btnketthuc
            // 
            this.btnketthuc.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.btnketthuc.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnketthuc.Image = global::Human.Properties.Resources.close_r1;
            this.btnketthuc.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btnketthuc.Location = new System.Drawing.Point(742, 529);
            this.btnketthuc.Name = "btnketthuc";
            this.btnketthuc.Size = new System.Drawing.Size(65, 28);
            this.btnketthuc.TabIndex = 19;
            this.btnketthuc.Text = "&Thoát";
            this.btnketthuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.btnketthuc.UseVisualStyleBackColor = true;
            this.btnketthuc.Click += new System.EventHandler(this.btnketthuc_Click);
            this.btnketthuc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cmbquy_KeyDown);
            // 
            // btnchon
            // 
            this.btnchon.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.btnchon.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnchon.Image = global::Human.Properties.Resources.ok;
            this.btnchon.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btnchon.Location = new System.Drawing.Point(671, 529);
            this.btnchon.Name = "btnchon";
            this.btnchon.Size = new System.Drawing.Size(65, 28);
            this.btnchon.TabIndex = 18;
            this.btnchon.Text = "  &Chọn";
            this.btnchon.UseVisualStyleBackColor = true;
            this.btnchon.Click += new System.EventHandler(this.btnchon_Click);
            this.btnchon.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cmbquy_KeyDown);
            // 
            // label4
            // 
            this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.label4.Location = new System.Drawing.Point(71, 524);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(58, 13);
            this.label4.TabIndex = 21;
            this.label4.Text = "Họ và Tên";
            this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label3
            // 
            this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.label3.Location = new System.Drawing.Point(5, 524);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(40, 13);
            this.label3.TabIndex = 20;
            this.label3.Text = "Mã NV";
            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // cmbhoten
            // 
            this.cmbhoten.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.cmbhoten.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbhoten.FormattingEnabled = true;
            this.cmbhoten.Location = new System.Drawing.Point(74, 540);
            this.cmbhoten.Name = "cmbhoten";
            this.cmbhoten.Size = new System.Drawing.Size(372, 21);
            this.cmbhoten.TabIndex = 16;
            this.cmbhoten.SelectedIndexChanged += new System.EventHandler(this.cmbhoten_SelectedIndexChanged);
            this.cmbhoten.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cmbquy_KeyDown);
            // 
            // txttongso
            // 
            this.txttongso.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.txttongso.BackColor = System.Drawing.SystemColors.Control;
            this.txttongso.ForeColor = System.Drawing.SystemColors.Control;
            this.txttongso.Location = new System.Drawing.Point(716, 545);
            this.txttongso.Name = "txttongso";
            this.txttongso.ReadOnly = true;
            this.txttongso.Size = new System.Drawing.Size(60, 20);
            this.txttongso.TabIndex = 26;
            this.txttongso.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // txtmanv
            // 
            this.txtmanv.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.txtmanv.Location = new System.Drawing.Point(8, 540);
            this.txtmanv.Name = "txtmanv";
            this.txtmanv.ReadOnly = true;
            this.txtmanv.Size = new System.Drawing.Size(60, 20);
            this.txtmanv.TabIndex = 15;
            this.txtmanv.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.txtmanv.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cmbquy_KeyDown);
            // 
            // groupBox1
            // 
            this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.groupBox1.Controls.Add(this.groupBox2);
            this.groupBox1.Location = new System.Drawing.Point(5, 143);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(779, 368);
            this.groupBox1.TabIndex = 24;
            this.groupBox1.TabStop = false;
            // 
            // checkupdate
            // 
            this.checkupdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.checkupdate.Location = new System.Drawing.Point(453, 547);
            this.checkupdate.Name = "checkupdate";
            this.checkupdate.Size = new System.Drawing.Size(75, 17);
            this.checkupdate.TabIndex = 17;
            this.checkupdate.Text = "Update All";
            this.checkupdate.UseVisualStyleBackColor = true;
            this.checkupdate.CheckedChanged += new System.EventHandler(this.checkupdate_CheckedChanged);
            this.checkupdate.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cmbquy_KeyDown);
            // 
            // checkin
            // 
            this.checkin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.checkin.Location = new System.Drawing.Point(569, 548);
            this.checkin.Name = "checkin";
            this.checkin.Size = new System.Drawing.Size(35, 17);
            this.checkin.TabIndex = 17;
            this.checkin.Text = "In";
            this.checkin.UseVisualStyleBackColor = true;
            this.checkin.CheckedChanged += new System.EventHandler(this.checkin_CheckedChanged);
            this.checkin.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cmbquy_KeyDown);
            // 
            // chk_uphd
            // 
            this.chk_uphd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.chk_uphd.Location = new System.Drawing.Point(453, 528);
            this.chk_uphd.Name = "chk_uphd";
            this.chk_uphd.Size = new System.Drawing.Size(110, 17);
            this.chk_uphd.TabIndex = 17;
            this.chk_uphd.Text = "Update hợp đồng";
            this.chk_uphd.UseVisualStyleBackColor = true;
            this.chk_uphd.CheckedChanged += new System.EventHandler(this.chk_uphd_CheckedChanged);
            this.chk_uphd.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cmbquy_KeyDown);
            // 
            // lbl_nhom
            // 
            this.lbl_nhom.Anchor = System.Windows.Forms.AnchorStyles.Top;
            this.lbl_nhom.Location = new System.Drawing.Point(520, 103);
            this.lbl_nhom.Name = "lbl_nhom";
            this.lbl_nhom.Size = new System.Drawing.Size(38, 13);
            this.lbl_nhom.TabIndex = 32;
            this.lbl_nhom.Text = "Nhóm:";
            this.lbl_nhom.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.lbl_nhom.Visible = false;
            // 
            // cbo_nhom
            // 
            this.cbo_nhom.Anchor = System.Windows.Forms.AnchorStyles.Top;
            this.cbo_nhom.FormattingEnabled = true;
            this.cbo_nhom.Items.AddRange(new object[] {
            "Bệnh viện trung tâm",
            "Y tế dự phòng",
            "Y tế xã phường"});
            this.cbo_nhom.Location = new System.Drawing.Point(564, 100);
            this.cbo_nhom.Name = "cbo_nhom";
            this.cbo_nhom.Size = new System.Drawing.Size(121, 21);
            this.cbo_nhom.TabIndex = 31;
            this.cbo_nhom.Visible = false;
            // 
            // txt_tieude
            // 
            this.txt_tieude.Anchor = System.Windows.Forms.AnchorStyles.Top;
            this.txt_tieude.Location = new System.Drawing.Point(168, 109);
            this.txt_tieude.Name = "txt_tieude";
            this.txt_tieude.Size = new System.Drawing.Size(275, 20);
            this.txt_tieude.TabIndex = 40;
            // 
            // label2
            // 
            this.label2.Anchor = System.Windows.Forms.AnchorStyles.Top;
            this.label2.AutoSize = true;
            this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.ForeColor = System.Drawing.Color.DarkBlue;
            this.label2.Location = new System.Drawing.Point(111, 110);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(51, 15);
            this.label2.TabIndex = 39;
            this.label2.Text = "Tiêu đề:";
            // 
            // chkl_nhomngach
            // 
            this.chkl_nhomngach.Anchor = System.Windows.Forms.AnchorStyles.Top;
            this.chkl_nhomngach.CheckOnClick = true;
            this.chkl_nhomngach.ColumnWidth = 165;
            this.chkl_nhomngach.FormattingEnabled = true;
            this.chkl_nhomngach.Location = new System.Drawing.Point(114, 25);
            this.chkl_nhomngach.MultiColumn = true;
            this.chkl_nhomngach.Name = "chkl_nhomngach";
            this.chkl_nhomngach.Size = new System.Drawing.Size(329, 79);
            this.chkl_nhomngach.TabIndex = 38;
            this.chkl_nhomngach.Validated += new System.EventHandler(this.chkl_nhomngach_Validated);
            // 
            // groupBox2
            // 
            this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.groupBox2.Controls.Add(this.dgvDanhSach);
            this.groupBox2.Location = new System.Drawing.Point(0, -8);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(779, 384);
            this.groupBox2.TabIndex = 25;
            this.groupBox2.TabStop = false;
            // 
            // dgvDanhSach
            // 
            this.dgvDanhSach.AllowUserToAddRows = false;
            this.dgvDanhSach.BackgroundColor = System.Drawing.SystemColors.Window;
            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
            dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
            this.dgvDanhSach.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
            this.dgvDanhSach.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dgvDanhSach.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.dataGridViewTextBoxColumn1,
            this.dataGridViewTextBoxColumn2,
            this.dataGridViewTextBoxColumn3,
            this.dataGridViewTextBoxColumn4,
            this.dataGridViewTextBoxColumn5,
            this.dataGridViewTextBoxColumn6,
            this.dataGridViewTextBoxColumn7,
            this.dataGridViewTextBoxColumn8,
            this.dataGridViewTextBoxColumn9,
            this.dataGridViewTextBoxColumn10,
            this.dataGridViewTextBoxColumn11,
            this.dataGridViewTextBoxColumn12,
            this.dataGridViewTextBoxColumn13,
            this.dataGridViewTextBoxColumn14,
            this.nhomngach,
            this.tennhom,
            this.dataGridViewTextBoxColumn15,
            this.dataGridViewTextBoxColumn16});
            this.dgvDanhSach.Cursor = System.Windows.Forms.Cursors.Default;
            this.dgvDanhSach.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dgvDanhSach.Location = new System.Drawing.Point(3, 16);
            this.dgvDanhSach.Name = "dgvDanhSach";
            this.dgvDanhSach.ReadOnly = true;
            dataGridViewCellStyle15.BackColor = System.Drawing.SystemColors.Control;
            dataGridViewCellStyle15.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            dataGridViewCellStyle15.ForeColor = System.Drawing.SystemColors.WindowText;
            dataGridViewCellStyle15.SelectionBackColor = System.Drawing.SystemColors.Highlight;
            dataGridViewCellStyle15.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
            dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
            this.dgvDanhSach.RowHeadersDefaultCellStyle = dataGridViewCellStyle15;
            this.dgvDanhSach.RowHeadersWidth = 20;
            this.dgvDanhSach.Size = new System.Drawing.Size(773, 365);
            this.dgvDanhSach.TabIndex = 0;
            // 
            // haison1
            // 
            this.haison1.Anchor = System.Windows.Forms.AnchorStyles.Top;
            this.haison1.Location = new System.Drawing.Point(449, 25);
            this.haison1.Name = "haison1";
            this.haison1.Size = new System.Drawing.Size(274, 68);
            this.haison1.TabIndex = 27;
            this.haison1.Validated += new System.EventHandler(this.haison1_Validated);
            this.haison1.MouseEnter += new System.EventHandler(this.haison1_MouseEnter);
            this.haison1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.haison1_KeyDown);
            // 
            // dataGridViewTextBoxColumn1
            // 
            this.dataGridViewTextBoxColumn1.DataPropertyName = "stt";
            dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle2;
            this.dataGridViewTextBoxColumn1.HeaderText = "Số TT";
            this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
            this.dataGridViewTextBoxColumn1.ReadOnly = true;
            this.dataGridViewTextBoxColumn1.Width = 40;
            // 
            // dataGridViewTextBoxColumn2
            // 
            this.dataGridViewTextBoxColumn2.DataPropertyName = "hoten";
            this.dataGridViewTextBoxColumn2.HeaderText = "Họ và Tên";
            this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
            this.dataGridViewTextBoxColumn2.ReadOnly = true;
            this.dataGridViewTextBoxColumn2.Width = 180;
            // 
            // dataGridViewTextBoxColumn3
            // 
            this.dataGridViewTextBoxColumn3.DataPropertyName = "tenbp";
            this.dataGridViewTextBoxColumn3.HeaderText = "Bộ phận";
            this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
            this.dataGridViewTextBoxColumn3.ReadOnly = true;
            this.dataGridViewTextBoxColumn3.Width = 180;
            // 
            // dataGridViewTextBoxColumn4
            // 
            this.dataGridViewTextBoxColumn4.DataPropertyName = "loaingach";
            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle3;
            this.dataGridViewTextBoxColumn4.HeaderText = "Loại Ngạch";
            this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
            this.dataGridViewTextBoxColumn4.ReadOnly = true;
            this.dataGridViewTextBoxColumn4.Width = 50;
            // 
            // dataGridViewTextBoxColumn5
            // 
            this.dataGridViewTextBoxColumn5.DataPropertyName = "mangach";
            dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            this.dataGridViewTextBoxColumn5.DefaultCellStyle = dataGridViewCellStyle4;
            this.dataGridViewTextBoxColumn5.HeaderText = "Mã ngạch";
            this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
            this.dataGridViewTextBoxColumn5.ReadOnly = true;
            this.dataGridViewTextBoxColumn5.Width = 60;
            // 
            // dataGridViewTextBoxColumn6
            // 
            this.dataGridViewTextBoxColumn6.DataPropertyName = "b_dau";
            dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            this.dataGridViewTextBoxColumn6.DefaultCellStyle = dataGridViewCellStyle5;
            this.dataGridViewTextBoxColumn6.HeaderText = "Bậc hiện hưởng";
            this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6";
            this.dataGridViewTextBoxColumn6.ReadOnly = true;
            this.dataGridViewTextBoxColumn6.Width = 50;
            // 
            // dataGridViewTextBoxColumn7
            // 
            this.dataGridViewTextBoxColumn7.DataPropertyName = "hs_lc";
            dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            dataGridViewCellStyle6.Format = "N2";
            this.dataGridViewTextBoxColumn7.DefaultCellStyle = dataGridViewCellStyle6;
            this.dataGridViewTextBoxColumn7.HeaderText = "Mức lương";
            this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
            this.dataGridViewTextBoxColumn7.ReadOnly = true;
            this.dataGridViewTextBoxColumn7.Width = 50;
            // 
            // dataGridViewTextBoxColumn8
            // 
            this.dataGridViewTextBoxColumn8.DataPropertyName = "hs_vk";
            dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            this.dataGridViewTextBoxColumn8.DefaultCellStyle = dataGridViewCellStyle7;
            this.dataGridViewTextBoxColumn8.HeaderText = "% Vượt khung";
            this.dataGridViewTextBoxColumn8.Name = "dataGridViewTextBoxColumn8";
            this.dataGridViewTextBoxColumn8.ReadOnly = true;
            this.dataGridViewTextBoxColumn8.Width = 50;
            // 
            // dataGridViewTextBoxColumn9
            // 
            this.dataGridViewTextBoxColumn9.DataPropertyName = "ngaybnngach";
            dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            dataGridViewCellStyle8.Format = "dd/mm/yyyy";
            this.dataGridViewTextBoxColumn9.DefaultCellStyle = dataGridViewCellStyle8;
            this.dataGridViewTextBoxColumn9.HeaderText = "Ngày hưởng";
            this.dataGridViewTextBoxColumn9.Name = "dataGridViewTextBoxColumn9";
            this.dataGridViewTextBoxColumn9.ReadOnly = true;
            // 
            // dataGridViewTextBoxColumn10
            // 
            this.dataGridViewTextBoxColumn10.DataPropertyName = "bac";
            dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            this.dataGridViewTextBoxColumn10.DefaultCellStyle = dataGridViewCellStyle9;
            this.dataGridViewTextBoxColumn10.HeaderText = "Bậc đề nghị";
            this.dataGridViewTextBoxColumn10.Name = "dataGridViewTextBoxColumn10";
            this.dataGridViewTextBoxColumn10.ReadOnly = true;
            this.dataGridViewTextBoxColumn10.Width = 50;
            // 
            // dataGridViewTextBoxColumn11
            // 
            this.dataGridViewTextBoxColumn11.DataPropertyName = "hs_lcmoi";
            dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            dataGridViewCellStyle10.Format = "N2";
            this.dataGridViewTextBoxColumn11.DefaultCellStyle = dataGridViewCellStyle10;
            this.dataGridViewTextBoxColumn11.HeaderText = "Mức lương đề nghị";
            this.dataGridViewTextBoxColumn11.Name = "dataGridViewTextBoxColumn11";
            this.dataGridViewTextBoxColumn11.ReadOnly = true;
            this.dataGridViewTextBoxColumn11.Width = 50;
            // 
            // dataGridViewTextBoxColumn12
            // 
            this.dataGridViewTextBoxColumn12.DataPropertyName = "ngaynang";
            dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            dataGridViewCellStyle11.Format = "dd/mm/yyyy";
            this.dataGridViewTextBoxColumn12.DefaultCellStyle = dataGridViewCellStyle11;
            this.dataGridViewTextBoxColumn12.HeaderText = "Ngày nâng";
            this.dataGridViewTextBoxColumn12.Name = "dataGridViewTextBoxColumn12";
            this.dataGridViewTextBoxColumn12.ReadOnly = true;
            // 
            // dataGridViewTextBoxColumn13
            // 
            this.dataGridViewTextBoxColumn13.DataPropertyName = "manv";
            dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            this.dataGridViewTextBoxColumn13.DefaultCellStyle = dataGridViewCellStyle12;
            this.dataGridViewTextBoxColumn13.HeaderText = "Manv";
            this.dataGridViewTextBoxColumn13.Name = "dataGridViewTextBoxColumn13";
            this.dataGridViewTextBoxColumn13.ReadOnly = true;
            this.dataGridViewTextBoxColumn13.Visible = false;
            // 
            // dataGridViewTextBoxColumn14
            // 
            this.dataGridViewTextBoxColumn14.DataPropertyName = "madv";
            dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            this.dataGridViewTextBoxColumn14.DefaultCellStyle = dataGridViewCellStyle13;
            this.dataGridViewTextBoxColumn14.HeaderText = "Mã DV";
            this.dataGridViewTextBoxColumn14.Name = "dataGridViewTextBoxColumn14";
            this.dataGridViewTextBoxColumn14.ReadOnly = true;
            this.dataGridViewTextBoxColumn14.Visible = false;
            // 
            // nhomngach
            // 
            this.nhomngach.DataPropertyName = "nhomngach";
            dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            this.nhomngach.DefaultCellStyle = dataGridViewCellStyle14;
            this.nhomngach.HeaderText = "Nhóm ngạch";
            this.nhomngach.Name = "nhomngach";
            this.nhomngach.ReadOnly = true;
            // 
            // tennhom
            // 
            this.tennhom.DataPropertyName = "tennhom";
            this.tennhom.HeaderText = "Tên nhóm";
            this.tennhom.Name = "tennhom";
            this.tennhom.ReadOnly = true;
            // 
            // dataGridViewTextBoxColumn15
            // 
            this.dataGridViewTextBoxColumn15.DataPropertyName = "nu_ngaysinh";
            this.dataGridViewTextBoxColumn15.HeaderText = "Column1";
            this.dataGridViewTextBoxColumn15.Name = "dataGridViewTextBoxColumn15";
            this.dataGridViewTextBoxColumn15.ReadOnly = true;
            this.dataGridViewTextBoxColumn15.Visible = false;
            // 
            // dataGridViewTextBoxColumn16
            // 
            this.dataGridViewTextBoxColumn16.DataPropertyName = "nam_ngaysinh";
            this.dataGridViewTextBoxColumn16.HeaderText = "Column2";
            this.dataGridViewTextBoxColumn16.Name = "dataGridViewTextBoxColumn16";
            this.dataGridViewTextBoxColumn16.ReadOnly = true;
            this.dataGridViewTextBoxColumn16.Visible = false;
            // 
            // frm_DNNL_truocthoihan_theoquy_lb
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(788, 569);
            this.ControlBox = false;
            this.Controls.Add(this.txt_tieude);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.chkl_nhomngach);
            this.Controls.Add(this.lbl_nhom);
            this.Controls.Add(this.cbo_nhom);
            this.Controls.Add(this.haison1);
            this.Controls.Add(this.chk_uphd);
            this.Controls.Add(this.checkupdate);
            this.Controls.Add(this.checkin);
            this.Controls.Add(this.checkxem);
            this.Controls.Add(this.btnketthuc);
            this.Controls.Add(this.btnchon);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.cmbhoten);
            this.Controls.Add(this.txttongso);
            this.Controls.Add(this.txtmanv);
            this.Controls.Add(this.groupBox1);
            this.ForeColor = System.Drawing.Color.DarkBlue;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.Name = "frm_DNNL_truocthoihan_theoquy_lb";
            this.ShowIcon = false;
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Đề nghị nâng lương";
            this.Load += new System.EventHandler(this.frm_DNNL_truocthoihan_lb_Load);
            this.groupBox1.ResumeLayout(false);
            this.groupBox2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.dgvDanhSach)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion
        private void frm_DNNL_truocthoihan_lb_Load(object sender, EventArgs e)
        {
            if (mDb.Mabv.Trim() == "209.5.09" || mDb.Mabv.Trim() =="209.5.06" || mDb.Mabv.Trim()=="209.5.04")
            {
                lbl_nhom.Visible = true;
                cbo_nhom.Visible = true;
                cbo_nhom.SelectedIndex = 0;
            }
            load_nhomngach();
            this.WindowState = FormWindowState.Maximized;
            checkupdate.Enabled = admin;
            chk_uphd.Enabled = admin;
        }
        private void load_nhomngach()
        {
            ds_nhomn = mDb.get_nhomngach();
            foreach (DataRow dr in ds_nhomn.Tables[0].Rows)
            {
                chkl_nhomngach.Items.Add(dr["tennhom"].ToString());
            }
        }
		private void butThoat_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
        private string g_manhom(string str)
        {
            string s = "";
            if (str.Trim().Length > 0)
            {
                string[] s1 = str.Split(',');
                for (int i = 0; i < s1.Length; i++)
                {
                    s = s + "'" + s1[i].ToString().Trim() + "',";
                }
            }
            return s;
        }        
        public DataSet getdata()
        {
            getngay();
            int stt = 0;
            string dk1="",dk2="",dk3="",dkngach="",sql1="",
            sql = " select 0 as stt,ho||' '||ten as hoten,case when phai='Nữ' then to_char(l.ngaysinh,'dd-mm-yyyy') end as nu_ngaysinh,case when phai<>'Nam' then null else to_char(l.ngaysinh,'dd-mm-yyyy') end as nam_ngaysinh";
            sql += " ,case when phai='Nữ' then l.namsinh end as nu_namsinh,case when phai<>'Nam' then null else l.namsinh end as nam_namsinh,mn.nhomngach,nn.tennhom";
            sql += " ,l.madv,tenbp,hd.macv,dt.tenvt,mn.loaingach,mangach,bac as b_dau,hs_lc,hd.hs_vk as hs_vk,to_char(ngaybnngach,'dd/mm/yyyy') as ngaybnngach,hd.lan,kt.giaykhen,kt.bangkhen,hd.tbnghihuu,hd.thangnangluong," + denngay + " as denngay,";
            dk1 = " (date_part('year',age(to_timestamp('" + denngay + "','dd/MM/yyyy'),ngaybnngach)))/3";
            dk2 = " (date_part('year',age(to_timestamp('" + denngay + "','dd/MM/yyyy'),ngaybnngach)))/2";
            dk3 = " date_part('year',age(to_timestamp('" + denngay + "','dd/MM/yyyy'),ngaybnngach)) -count(e.manv)";
            dkngach = " mn.loaingach in ('A0','A1','A2','A2.1','A3','A4')";
            
            sql += " case when (case when " + dkngach + " then round(" + dk1 + ") else ";
            sql += " round(" + dk2 + ") end+bac)>baccuoi then baccuoi else case when " + dkngach;
            sql += " then round(" + dk1 + ") else round(" + dk2 + ") end+bac end as bac,0.0 as hs_lcmoi,";
          
            sql+=" to_char(to_timestamp(to_char(ngaybnngach,'dd/mm')||'/'||to_char(case when (case when " + dkngach + " then round(" + dk1 + ") else";
            sql+=" round(" + dk2 + ") end+bac)>baccuoi then baccuoi-bac else case when " + dkngach ;
            sql+=" then round(" + dk1 + ")*3 else";
            sql+=" round(" + dk2 + ")*2 end end + date_part('year',ngaybnngach),'9999S'),'dd/mm/yyyy'),'dd/mm/yyyy') as ngaynang";
            sql += " ,l.manv,hd.luonghd,bp.sothutu as stt_bp,dt.stt as stt_bp,mn.stt as stt_mn";

            sql += " from " + mDB.user + ".llnv l inner join " + mDB.user + ".hopdong hd on l.manv=hd.manv  ";
            sql += " inner join " + mDB.user + ".bophan bp on l.madv =bp.madv inner join " + mDB.user + ".ctdaotao dt on dt.mactdt=l.nnghiep";
            sql += " inner join "+mDB.user+".dmcv cv on hd.macv=cv.macv";
            sql += " join " + mDB.user + ".mangach mn on mn.ma=hd.mangach ";
            sql += " inner join " + mDB.user + ".nhomngach nn on nn.manhom=mn.nhomngach";
            sql += " left join " + mDB.user + ".dmnhiemvu e on l.manv=e.manv and date_part('year',ngaybnngach)>=to_number(e.nam,'9999S')";
            sql += " inner join " + mDB.user + ".max_lan ml on hd.manv=ml.manv";
            sql += " left join " + mDB.user + ".khenthuong kt on l.manv=kt.manv";
            sql += " where mangach<>'00.000' and to_timestamp(ngayhd,'dd/MM/yyyy')<to_timestamp('" + denngay + "','dd/MM/yyyy') and ";
            sql += "(hd.ngaynghi is null or to_timestamp(ngaynghi,'dd/MM/yyyy')>to_timestamp('" + denngay + "','dd/MM/yyyy')) and bac<baccuoi and mn.loaingach<>'' ";
            sql += " and hd.lan=ml.lan and (kt.giaykhen = 'True' or kt.bangkhen='true' and to_number(kt.nam) > to_number(to_char(hd.ngaybnngach,'yyyy'))) or hd.tbnghihuu=1 ";

            sql += " group by l.ho,l.ten,l.phai,l.ngaysinh,l.namsinh,hd.mangach,mn.nhomngach,nn.tennhom,hd.hs_lc,ngaybnngach,tenbp,mn.loaingach,hd.hs_vk,hd.bac,mn.baccuoi,l.manv,l.madv,bp.sothutu,dt.stt,mn.stt ";
            sql += " ,dt.tenvt,hd.luonghd,kt.nam,kt.giaykhen,kt.bangkhen,hd.tbnghihuu,hd.thangnangluong,hd.lan,kt.giaykhen,kt.bangkhen,hd.tbnghihuu,hd.thangnangluong,hd.macv,bp.mabsoft";
            sql += " having to_timestamp(Replace(to_char(case when (case when " + dkngach;
            sql += " then round(" + dk1 + ") else round(" + dk2 + ") end+bac)>baccuoi ";
            sql += " then baccuoi-bac else case when " + dkngach + "then round("+dk1+")*3 else ";
            sql += " round(" + dk2 + ")*2 end end +";
            sql += " date_part('year',ngaybnngach),'9999S')||to_char(ngaybnngach,'mm-dd'),'+','-'),'yyyy-mm-dd') ";
            sql += " between to_timestamp('" + tungay + "','dd/MM/yyyy') and to_timestamp('" + denngay + "','dd/MM/yyyy')";
            if (s_manhom.Trim() != "")
            {
                string s1 = g_manhom(s_manhom.Substring(0, s_manhom.Trim().Length - 1));
                sql += " and mn.nhomngach in (" + s1.Substring(0, s1.Length - 1) + ")";
            }
            if (cbo_nhom.SelectedIndex == 0)
                sql += " and bp.mabsoft in ('L','C','P','K')";
            if (cbo_nhom.SelectedIndex == 1)
                sql += " and bp.mabsoft in ('D')";
            if (cbo_nhom.SelectedIndex == 2)
                sql += " and bp.mabsoft in ('X')";
            sql += " order by bp.sothutu,dt.stt,mn.stt ";
            sql1 = " select * from " + mDb.user + ".mangach order by stt";
           
            ds = mDb.get_data(sql,sql1);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string ngay="",thang="",nam="",ngaynang="";
                decimal thang1=0,nam1=0,tbnh=0,thangnl=0,thang2=0;
                bool gk = false,bk=false;
                gk = dr["giaykhen"].ToString()!="" ? bool.Parse(dr["giaykhen"].ToString()):false;
                bk = dr["bangkhen"].ToString()!=""? bool.Parse(dr["bangkhen"].ToString()):false ;
                ngay = dr["ngaynang"].ToString().Substring(0, 2).Trim();
                thang = dr["ngaynang"].ToString().Substring(3, 2).Trim();
                nam = dr["ngaynang"].ToString().Substring(6, 4).Trim();
                tbnh=  decimal.Parse(dr["tbnghihuu"].ToString());
                thangnl = dr["thangnangluong"].ToString()!=""? decimal.Parse(dr["thangnangluong"].ToString().Trim()):0;
                thang1=decimal.Parse(thang)+6;
                thang2 = decimal.Parse(thang) - 6;
                nam1=decimal.Parse(nam)-1;
                if (gk)
                {
                    if (decimal.Parse(thang) <= 6)
                    {
                        ngaynang = ngay +"/" + thang1.ToString().PadLeft(2,'0') +"/"+ nam1.ToString();
                    }
                    else
                    {
                        ngaynang = ngay +"/"+ thang2.ToString().PadLeft(2,'0') +"/"+ nam;
                    }
                }
                if (bk)
                {
                    ngaynang = ngay + "/" + thang + "/" + nam1.ToString();
                }
                if (tbnh == 1)
                {
                    if (thangnl == 12)
                    {
                        ngaynang = ngay + "/" + thang + "/" + nam1.ToString();
                    }
                    if (thangnl < 12)
                    {
                        if (thangnl < decimal.Parse(thang))
                        {
                            decimal t = decimal.Parse(thang) - thangnl;
                            ngaynang = ngay + "/" + t.ToString().PadLeft(2,'0') + "/" + nam;
                        }
                        else
                        {
                            decimal t = decimal.Parse(thang) + 12 - thangnl;
                            ngaynang = ngay + "/" + t.ToString().PadLeft(2,'0') + "/" + nam1.ToString();
                        }
                    }
                }
                dr["ngaynang"] = ngaynang.ToString();
            }
            
            if (ds != null)
            {
                ds.WriteXml("..\\xml\\h_DSDNNL_truocthoihan_theoquy_lb.xml",XmlWriteMode.WriteSchema);
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    stt ++;
                    DataRow[] r = ds.Tables[1].Select("ma='" + dr["mangach"].ToString() + "'");
                    if (r.Length > 0)
                    {
                        dr["stt"] = stt.ToString();
                        dr["hs_lcmoi"] = r[0]["b" + dr["bac"].ToString()];
                        
                    }

                }
                dgvDanhSach.DataSource = ds.Tables[0];

                cmbhoten.DisplayMember = "hoten";
                cmbhoten.ValueMember = "manv";
                cmbhoten.DataSource = ds.Tables[0];

                txttongso.Text = ds.Tables[0].Rows.Count.ToString();
            }
            return null;
        }

        private void cmbquy_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }

        private void cmbquy_SelectedIndexChanged(object sender, EventArgs e)
        {
            getdata();
        }

        private void txtnam_Validated(object sender, EventArgs e)
        {
            cmbquy_SelectedIndexChanged(sender, e);
        }

        private void txtnam_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '\b')
                e.KeyChar = '\0';
        }

        public void getngay()
        {
            tungay = haison1.tungay;
            denngay = haison1.denngay;           
        }
        private void btnchon_Click(object sender, EventArgs e)
        {
            ReportName = "h_DSDNNL_truocthoihan_theoquy_lb.rpt";
            frmReport f = new frmReport(mDb, ds, ReportName,msg,title,user_dn);
            switch (checkxem.Checked)
            {
                case true:
                    f.Show();
                    if (checkupdate.Checked)
                    {
                        Update_bacluong(ds);
                    }
                    if (chk_uphd.Checked)
                    {
                        Update_bacluong_1(ds);
                    }
                    break;
                

                case false:
                    if (checkin.Checked)
                    {
                        f.PreviewReport();
                        f.butIn_Click(null, null);
                    }
                    if (checkupdate.Checked)
                        Update_bacluong(ds);
                    break;
            }
        }

        private void btnketthuc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        
        private void Update_bacluong_1(DataSet dsbl)
        {

            if (DateTime.Now.Date >= Convert.ToDateTime(tungay))
            {
                string mmyy = DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Year.ToString().Substring(2, 2),
                    baccu = "", bacmoi = "";
                string manv_n = txtmanv.Text.Trim();
                foreach (DataRow dr in dsbl.Tables[0].Rows)
                {
                    
                    if (manv_n == dr["manv"].ToString())
                    {
                        baccu = dr["b_dau"].ToString().Trim() + "  |  " + dr["hs_lc"].ToString().Trim();
                        bacmoi = dr["bac"].ToString().Trim() + "  |  " + dr["hs_lcmoi"].ToString().Trim();
                        mDb.update_bacluong(dr["manv"].ToString(), mmyy, dr["ngaybnngach"].ToString(), baccu, dr["ngaynang"].ToString(), bacmoi, dr["mangach"].ToString(), dr["mangach"].ToString(), DateTime.Now.Date.ToString("dd/MM/yyyy"),dr["madv"].ToString().Trim(),dr["macv"].ToString().Trim());

                        update_hs_luonghd(dr["manv"].ToString(), dr["hs_lcmoi"].ToString(), dr["ngaynang"].ToString(), dr["bac"].ToString(), decimal.Parse(dr["lan"].ToString()));
                    }
                }
            }
            else
            {
                MessageBox.Show(lan.Change_language_MessageText("Thời điểm nâng bậc lương không hợp lệ !"));
               
            }
        }

        public void Update_bacluong(DataSet dsbl)
        {
            if (DateTime.Now.Date >= Convert.ToDateTime(tungay))
            {
                string mmyy = DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Year.ToString().Substring(2, 2),
                    baccu = "", bacmoi = "";
                foreach (DataRow dr in dsbl.Tables[0].Rows)
                {
                    baccu = dr["b_dau"].ToString().Trim() + "  |  " + dr["hs_lc"].ToString().Trim();
                    bacmoi = dr["bac"].ToString().Trim() + "  |  " + dr["hs_lcmoi"].ToString().Trim();
                    mDb.update_bacluong(dr["manv"].ToString(), mmyy, dr["ngaybnngach"].ToString(), baccu, dr["ngaynang"].ToString(), bacmoi, dr["mangach"].ToString(), dr["mangach"].ToString(), DateTime.Now.Date.ToString("dd/MM/yyyy"), dr["madv"].ToString().Trim(), dr["macv"].ToString().Trim());

                    update_hs_luonghd(dr["manv"].ToString(), dr["hs_lcmoi"].ToString(), dr["ngaynang"].ToString(), dr["bac"].ToString(),decimal.Parse(dr["lan"].ToString()));
                }
            }
            else
            {
                MessageBox.Show(lan.Change_language_MessageText("Thời điểm nâng bậc lương không hợp lệ !"));
               
            }
        }

        public bool update_hs_luonghd(string manv, string hs_lc, string ngay,string bac ,decimal lan)
        {
           return mDb.update_hs_luonghd( manv, hs_lc, ngay, bac , lan);
        }

        private void cmbhoten_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtmanv.Text = cmbhoten.SelectedValue.ToString();
        }

        private void checkxem_CheckedChanged(object sender, EventArgs e)
        {
            if (!checkupdate.Checked)
            {
                if (checkxem.Checked)
                    checkin.Checked = false;
                else
                    checkin.Checked = true;
            }
        }

        private void checkin_CheckedChanged(object sender, EventArgs e)
        {
            if (!checkupdate.Checked)
            {
                if (checkin.Checked)
                    checkxem.Checked = false;
                else
                    checkxem.Checked = true;
            }
        }

        private void chk_uphd_CheckedChanged(object sender, EventArgs e)
        {
            if (chk_uphd.Checked == true)
            {
                checkupdate.Checked = false;
                checkupdate.Enabled = false;
            }
            else
            {
                checkupdate.Enabled = true;
            }
        }

        private void checkupdate_CheckedChanged(object sender, EventArgs e)
        {
            if (checkupdate.Checked == true)
            {
                chk_uphd.Checked = false;
                chk_uphd.Enabled = false;
            }
            else
            {
                chk_uphd.Enabled = true;
            }
        }

        private void haison1_MouseEnter(object sender, EventArgs e)
        {
            getdata();
        }

        private void haison1_Validated(object sender, EventArgs e)
        {
            getdata();
        }

        private void haison1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }

        private void chkl_nhomngach_Validated(object sender, EventArgs e)
        {
            try
            {
                chkl_nhomngach.SetItemCheckState(chkl_nhomngach.SelectedIndex, CheckState.Checked);
                s_manhom = ""; s_tennhom = "";
                for (int i = 0; i < chkl_nhomngach.Items.Count; i++)
                {
                    if (chkl_nhomngach.GetItemChecked(i))
                    {
                        s_manhom += mDb.getrowbyid(ds_nhomn.Tables[0], "tennhom='" + chkl_nhomngach.Items[i].ToString() + "'")["manhom"].ToString() + ",";
                        s_tennhom += chkl_nhomngach.Items[i].ToString() + ",";
                    }
                }
                s_tennhom = s_tennhom.Trim().Substring(0, s_tennhom.Length - 1);
                txt_tieude.Text = s_tennhom;
            }
            catch { }
        }       
	}
}
